<template>
	<view class="mainpadding">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="tupbox dingwei" :class="index==0?'':'margin_top9'" v-for="(item,index) in list.data" :key="item.id">
			<image :src="item.bg_image_text" mode=""></image>
			<view class="nkbtn weizhi">{{item.price}}天/{{item.days}}天</view>
			<view class="nzti zitiwz">{{item.name}}</view>
			<view class="flexright margin_top2">
				<view class="baibtn margin_right2" @click="delitem(item.id)">移除</view>
				<view class="lvbtn" @click="jumpurl('/pages_mypage/quanyiktj?id=',item.id)">编辑</view>
			</view>
		</view>
		<view class="gudingdb mainpadding">
			<view class="bigbtn"  @click="jumpurltj('/pages_mypage/quanyiktj')">添加权益卡</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				modal:{
					modalShow:false,
					title:"是否确认删除当前权益卡？",
				},
				currentid:"",
				user_zbfapply_listid:""
			}
		},
		onLoad(options) {
			this.user_zbfapply_listid=options.user_zbfapply_listid
		},
		onShow() {
			this.init()
		},
		methods: {
			delitem(id){
				this.modal.modalShow = true
				this.currentid = id
			},
			modalSure(){
				if(this.modal.title=="是否确认删除当前权益卡？"){
					httpRequest.request("/api/user/deleteUserHyqycard", 'GET', {
						id:this.currentid,
						user_zbfapply_id:this.user_zbfapply_listid
					}).then(res => {
						httpRequest.toast(res.msg)
						if(res.code==1){
							this.init()
						}
					})
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					user_zbfapply_id:this.user_zbfapply_listid
				}
				let url = '/api/user/userHyqycardIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转详情
			tzxq() {
				uni.navigateTo({
					url: '/pages_mypage/changdihuiyuankxq'
				})
			},
			jumpurl(url, id) {
				uni.navigateTo({
					url: url + id+"&user_zbfapply_listid="+this.user_zbfapply_listid
				})
			},
			jumpurltj(url) {
				uni.navigateTo({
					url: url + "?user_zbfapply_listid="+this.user_zbfapply_listid
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.margin_top9{
		margin-top: 100rpx;
	}
	.ckzi {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #576E8B;
	}

	.ykzt {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #DC9253;
	}

	.jkzt {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #E8A10C;
	}

	.zitiwz {
		position: absolute;
		top: 90rpx;
		left: 190rpx;
	}

	.ckbtn {
		background-color: #A1BCDE;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 140rpx;
		height: 50rpx;
	}

	.nzti {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #F5E1B5;
	}

	.ykbtn {
		background-color: #F9C99E;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #F2892E;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 140rpx;
		height: 50rpx;
	}

	.jkbtn {
		background-color: #FFE8C0;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #F8890A;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 140rpx;
		height: 50rpx;
	}

	.nkbtn {
		background-color: #D3B47D;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #2D2113;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 0 15rpx;
		height: 50rpx;
	}

	.weizhi {
		position: absolute;
		top: 30rpx;
		left: 0;
	}

	.tupbox {
		width: 100%;
		height: 240rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
		}
	}
</style>